const router = require('../../utils/router.js')
const api = require('../../utils/request.js') 
//获取应用实例
const app = getApp()
Page({
  data: {
    StatusBar: app.globalData.StatusBar,
    CustomBar: app.globalData.CustomBar,
    Custom: app.globalData.Custom,
    imageHost: api.IMG_HOST,
    scrollTop: 0,
    galleryList: [],
    bannerImageHeight: 0
  },
  tapNavigateToUrl({ currentTarget }) {
    router.push(currentTarget.dataset.url)
  },
  onShow() {
    let query = wx.createSelectorQuery()
    query.select('#bannerImage').boundingClientRect().exec(res => {
      this.setData({
        bannerImageHeight: res[0].height
      })
    })
  },
  /**
   * 获取图册列表
   */
  getGalleryList() {
    return new Promise(resolve => {
      api._get('/User/Gallery/List', {
        index: 1
      }).then(res => {
        if (res.Code === 100000) {
          resolve(res.Data)
        }
      })
    })
  },
  onLoad: function () {
    this.getGalleryList().then(data => {
      this.setData({
        galleryList: data
      })
    })
  },
  onPageScroll(option) {
    this.setData({
      scrollTop: option.scrollTop
    })
  }
})
